<?php
include("../class/mysql.class.php");
include("../submit/Articles/get_list_article.php");

$obj = new Mysql ();
// hedhia stat 2

  
    
    $rq = "select 
                  a.ref_article, a.designation, a.Quantite, a.photo_name, a.prix
    ";
    
    if(!empty($_POST["id_type"])){
      $rq .= " ,t.id_type ";
    }    
    if(!empty($_POST["id_lieu"])){
      $rq .= " ,l.id_lieu ";
    }    
    
    $rq .="
          from 
                st_article a ";
        
        if(!empty($_POST["id_type"])){
          $rq .= " ,st_att_type_article t ";
        }    
        if(!empty($_POST["id_lieu"])){
          $rq .= " ,st_att_lieu_article l ";
        }    
              
        $rq .= "where 1 ";
       
            
          if(!empty($_POST["id_article"])){
            $rq .=" AND a.id_article=".$_POST['id_article'];
            //echo "<br> id article ".$_POST["id_article"]."<br>";       
          }

          if(!empty($_POST["id_type"])){
            $rq .=" AND t.id_type = a.id_type AND a.id_type = ".$_POST["id_type"];       
            //echo "<br> TYPE".$_POST["id_type"]."<br>";       
          }

          if(!empty($_POST["id_lieu"])){
            $rq .=" AND l.id_lieu = a.id_lieu AND a.id_lieu = ".$_POST["id_lieu"];       
            //echo "<br> LIEU ".$_POST["id_lieu"]."<br>";       
          }

          
        //echo $rq;
        $rs = mysql_query($rq);
  ?>
	<div id="printablediv">
  <div id="container">

 <table cellpadding="0" cellspacing="0" border="0" class="table table-striped table-bordered" id="example">
    <thead>
    <tr>
        <th style="text-align:left;width:50px;">#</th> 
        <th>Référence</th>
        <th style="width: 550px;">Désignation</th>
        <th>Qté Stock</th>
        <th>Prix de Vente</th>
    </tr>
</thead>
<tbody>
    
    <?php  
    $i = 0;
    $cpt = 1;
    $qt_Total = 0;
    while($row = mysql_fetch_object($rs))
    {
      
    ?>
    
    <tr>
        <td style="text-align:left;width:50px;"><?php echo $cpt?></td>
        <td style="text-align:left;width:150px;"><?php echo '<a class="fancybox-effects-a" href="'.$row->photo_name.'">'.$row->ref_article.'</a>' ?></td>
        <td style="text-align:left;width:350px;"><?php echo $row->designation?></td>
        <td style="text-align:left;width:150px;"><?php echo number_format($row->Quantite, 0, '', ' ')?></td>
        <td style="text-align:left;width:150px;"><?php echo $row->prix?></td>
        
     
    </tr>

    <?php 
    $qt_Total += (int)$row->Quantite;
    $cpt++;
    $i++;
    }
    ?>
    
      </tbody>
  </table>
  
    <h4>Qt Total : <?php echo number_format($qt_Total, 0, '', ' ').', Nombre des Articles : '.$i;?></h4>
  
  </div>
  </div>
  <input class="btn btn-primary btn-small" type="button" value="Imprimer" onclick="javascript:printDiv('printablediv')" style="padding: 6px 24px; margin-top: 20px;font-weight: bold;" />
  <?php
    include("../template/footer-ajax.php") ;
  ?>